package com.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.project.bean.CoachBean;
import com.project.bean.GymBean;
import com.project.bean.PageBean;
import com.project.bean.StudentBean;
import com.project.bean.UserBean;
import com.project.service.ICoachService;
import com.project.service.IGymService;
import com.project.service.IStudentService;

@Controller
public class MapController {
	@Autowired
	private IStudentService stuService;
	@Autowired
	private ICoachService coaService;
	@Autowired
	private IGymService gymService;

	/**
	 * 学生地图父页用
	 * 
	 * @param page
	 * @param map
	 * @return
	 */
	/*
	 * @RequestMapping("/map_student") public String showAllStu(int page,ModelMap
	 * map) { PageBean bean = stuService.findAllStudentToMap(page, 7);
	 * map.put("page", bean); return "/user_map.html"; }
	 */
	//查询所有学员
	@GetMapping("/map/stu")
	@ResponseBody
	public List<StudentBean> showAllStu(){
		List<StudentBean> list = stuService.findAllStu();
		/*
		 * for (StudentBean studentBean : list) { System.out.println(studentBean); }
		 */
		return list;
	}
	//查询所有教练
	@GetMapping("/map/coach")
	@ResponseBody
	public List<CoachBean> showAllCoach(){
		List<CoachBean> list = coaService.findAllCoachs();
		/*
		 * for (CoachBean coachBean : list) { System.out.println(coachBean); }
		 */
		return list;
	}
	
	//查询所有场馆
	@GetMapping("/map/gym")
	@ResponseBody
	public List<GymBean> showAllGym(){
		List<GymBean> list = gymService.findAllGym();
		/*
		 * for (GymBean gymBean : list) { System.out.println(gymBean); }
		 */
		return list;
	}
	/**
	 * 学生地图页面用
	 * 
	 * @param page
	 * @return
	 */
	@GetMapping("/map/studentMap/{page}")
	@ResponseBody
	public PageBean showAllStuMap(@PathVariable("page") int page) {
		PageBean bean = stuService.findAllStudentToMap(page, 7);
		return bean;
	}
	

	/**
	 * 教练地图父页面
	 * 
	 * @param page
	 * @param map
	 * @return
	 */
	/*
	 * @GetMapping("/map_coach") public String showAllCoa(int page,ModelMap map) {
	 * PageBean bean = coaService.findAllCoachsByPage(page, 7);
	 * //System.out.println(bean);
	 * 
	 * List<UserBean> list =(List<UserBean>) bean.getList(); for (UserBean userBean
	 * : list) { System.out.println(userBean); }
	 * 
	 * map.put("page",bean); map.put("url","/coach_idex_other?cUId={id}"); return
	 * "/user_map.html"; }
	 */
	/**
	 * 教练地图页面
	 * 
	 * @param page
	 * @return
	 */
	@GetMapping("/map/coaMap/{page}")
	@ResponseBody
	public PageBean showAllcoaMap(@PathVariable("page") int page) {
		PageBean bean = coaService.findAllCoachsByPage(page, 7);
		return bean;
	}

	/**
	 * 场馆地图父页面
	 * 
	 * @param page
	 * @param map
	 * @return
	 */
	/*
	 * @GetMapping("/map_gym") public String showAllGym(int page, ModelMap map) {
	 * PageBean bean = gymService.findGymByPage(page, 7); return
	 * "redirect:/user_map.html"; }
	 */
	/**
	 * 场馆地图页面
	 * 
	 * @param page
	 * @return
	 */
	@GetMapping("/map/gymMap/{page}")
	@ResponseBody
	public PageBean showAllGymMap(@PathVariable("page") int page) {
		PageBean bean = gymService.findGymByPage(page, 7);
		System.out.println(bean);
		return bean;
	}
}
